import router from '@system.router';
import prompt from '@system.prompt';

export default {
    data: {
        home_img: "/common/images/home/home.png",
        guangguang_img: "/common/images/home/guangguang.png",
        msg_img: "/common/images/home/msg.png",
        shopping_cart_img: "/common/images/home/shopping_cart.png",
        user_img: "/common/images/home/user.png",
        title: 'World',
    },
    onInit() {
        if (router.getParams() != null) {
            const tag = router.getParams()['tag']
            if (tag != null) {
                this.click_img(tag)
            }
        }
    },
    refresh_img() {
        this.home_img = "/common/images/home/home.png"
        this.guangguang_img = "/common/images/home/guangguang.png"
        this.msg_img = "/common/images/home/msg.png"
        this.shopping_cart_img = "/common/images/home/shopping_cart.png"
        this.user_img = "/common/images/home/user.png"
    },

    click_img(tag) {
        console.log(tag + " is clicked..")
        switch (tag) {
            case "home_page":
            {
                this.refresh_img()
                console.log("home page...")
            }
                break
            case "guangguang":
            {
                this.refresh_img()
                this.home_img = "/common/images/home/home2.jpg"
                this.guangguang_img = "/common/images/home/guanguang_click.png"
            }
                break
            case "msg":
            {
                this.refresh_img()
                this.home_img = "/common/images/home/home2.jpg"
                this.msg_img = "/common/images/home/msg_click.png"
            }
                break
            case "shopping_mart":
            {
                this.refresh_img()
                this.home_img = "/common/images/home/home2.jpg"
                this.shopping_cart_img = "/common/images/home/shopping_cart_click.png"
                break
            }
            case "user":
            {
                this.refresh_img()
                this.home_img = "/common/images/home/home2.jpg"
                this.user_img = "/common/images/home/user_click.png"
            }
        }
    },
    to_home_page() {
        console.log("route to home page")
        router.push({
            uri: 'pages/home/home',
            params: "home_page"
        })
    },
    to_guangguang() {
        console.log("route to guangguang")
        prompt.showToast({
            message: "该功能暂未实现，请耐心等待版本更新",
            duration: 2000
        })
    },
    to_message() {
        console.log("route to message")
        router.push({
            uri: 'pages/message/message',
            params: {
                "tag": "msg"
            }
        })
    },
    to_shopping_cart() {
        console.log("route to shopping cart")
        router.push({
            uri: 'pages/cart/cart',
            params: {
                "tag": "shopping_mart"
            }
        })
    },
    to_user() {
        console.log("route to user")
        router.push({
            uri: 'pages/user/user',
            params: {
                "tag": "user"
            }
        })
    }
}